<% 
    var headContent = {
  %>
  <style type="text/css">
  .tr-selected {
    background-color: #fcb287;
    border: 1px solid #fcb287;
  </style>
  <script type="text/javascript">
   $(function(){
      $("body").on('click', '.list-item', function() {
       $(".list-item").removeClass("tr-selected");
       $(this).addClass('tr-selected');
      });
      $("body").on('click', '#searchBtn', function() {

          var keywords = {
              keyword:$("#keyword").val(),
              queryType:$("#queryType").val()
          }
          var url = "${base}/multiUserAuthConfig/dialogCity?keywords="+JSON.stringify(keywords);
        document.location.href=url;
      });
       //当本页面属于其他页面的弹出页面时
       if (frameElement != null && frameElement.api != null) {
        var api = frameElement.api;
        api.button({
          id: 'valueOk',
          name: '确定',
          focus: true,
          callback: function () {
          
            var $idsCheckedCheck = $("[name='idsCity']:checked");
            console.info($idsCheckedCheck);
            //var $deleteButton = $("#deleteButtonCity");// 删除按钮
            //var ids = $idsCheckedCheck.serialize();
       		var ids =[]; 
			$idsCheckedCheck.each(function(){ 
				ids.push($(this).val()); 
			}); 
            if ($idsCheckedCheck.length < 1) {
              alert("您没有选择任何数据！");
              return false;
            } else {
              if (api.data != 'undefined') {
                api.data(ids);
              }
              return true;
            }
          }
        }, { id: 'valueCancel', name: '取消' });
      }
      
      $("#allCheckCity").click(function() {
          $('input[name="idsCity"]').prop("checked",this.checked);
          
      });
   
      var $citySubBox = $("input[name='idsCity']");
      
      $citySubBox.click(function(){
        console.log('length:'+$("input[name='idsCity']:checked").length);
        console.log('$citySubBox.length:' + $citySubBox.length);
        
        $("#allCheckCity").prop("checked", $citySubBox.length == $("input[name='idsCity']:checked").length ? true : false);
      
      });
                  
   });
   

      
   </script>
  <%
};
%>
<%layout("/common/_layout.html",{head:headContent}){ %>
  <%#ajax userTable:{%>
   <div class="am-g">
     <div class="am-u-sm-6">&nbsp; </div>
     <div class="am-u-sm-3">
       <select id="queryType" name="queryType" data-am-selected="{btnSize: 'sm'}">
         <option <%if (isEmpty(queryType)||queryType=="fuzzy"){%>
                     selected = "selected"
                  <%}%> value="fuzzy">模糊查询</option>
         <option <%if (!isEmpty(queryType) && queryType=="exact"){%>
                     selected = "selected"
                  <%}%> value="exact">精确查询</option>
       </select>
     </div>
     <div class="am-u-sm-3">
       <div class="am-input-group am-input-group-sm">        
         <input type="text" class="am-form-field" id="keyword" placeholder="地市名称" value="${keyword!}">
         <span class="am-input-group-btn">
           <button class="am-btn am-btn-default" type="button" id="searchBtn" >搜索</button>
         </span>
       </div>
     </div>
   </div>

   <div class="am-g">
     <div class="am-u-sm-12">
         <table class="am-table table-main">
             <thead>
                 <tr>
                     <th class="table-check">
                      <input type="checkbox"  id="allCheckCity"/>
                     </th>
                     <th>机构ID</th>
                     <th>渠道编码</th>
                     <th>名称</th>           
                 </tr>
             </thead>
          <tbody>
             <%for(list in pager.list!){%>
                <tr class="list-item" data-id="${list.id}" data-name="${list.DisplayName}">
                 <td> <input type="checkbox" name="idsCity" value="${list.id}"> </td>
                 <td>${list.id}</td>
                 <td>${list.NumCode}</td>
                 <td>${list.DisplayName}</td>    
               </tr>
             <%}%> 
          </tbody>
       </table>
        <div class="am-cf">
           <!-- 分页 -->
           <%if (pager.list.~size > 0){%>
               <div class="am-fr">
                   <% include("/admin/multiuser/multi_user_auth_config_dialog_pager.tpl"){}%>
               </div>
           <%}else{%>
               <div class="am-kai">
                 <h3>没有找到任何记录!</h3>
               </div>
           <%}%>
        </div>
       <%}%>
     </div>
   </div>
   
<%}%>
